; RUN: clspv-opt --passes=replace-opencl-builtin %s -o %t
; RUN: FileCheck %s < %t

target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir-unknown-unknown"

define spir_func void @test(ptr addrspace(1) %gu, ptr addrspace(1) %gs, ptr addrspace(3) %lu, ptr addrspace(3) %ls) {
entry:
  %call = tail call spir_func i32 @_Z10atomic_incPU3AS1Vj(ptr addrspace(1) %gu)
  %call1 = tail call spir_func i32 @_Z10atomic_incPU3AS3Vj(ptr addrspace(3) %lu)
  %call2 = tail call spir_func i32 @_Z10atomic_incPU3AS1Vi(ptr addrspace(1) %gs)
  %call3 = tail call spir_func i32 @_Z10atomic_incPU3AS3Vi(ptr addrspace(3) %ls)
  %call4 = tail call spir_func i32 @_Z8atom_incPU3AS1Vj(ptr addrspace(1) %gu)
  %call5 = tail call spir_func i32 @_Z8atom_incPU3AS3Vj(ptr addrspace(3) %lu)
  %call6 = tail call spir_func i32 @_Z8atom_incPU3AS1Vi(ptr addrspace(1) %gs)
  %call7 = tail call spir_func i32 @_Z8atom_incPU3AS3Vi(ptr addrspace(3) %ls)
  %call8 = tail call spir_func i32 @_Z10atomic_decPU3AS1Vj(ptr addrspace(1) %gu)
  %call9 = tail call spir_func i32 @_Z10atomic_decPU3AS3Vj(ptr addrspace(3) %lu)
  %call10 = tail call spir_func i32 @_Z10atomic_decPU3AS1Vi(ptr addrspace(1) %gs)
  %call11 = tail call spir_func i32 @_Z10atomic_decPU3AS3Vi(ptr addrspace(3) %ls)
  %call12 = tail call spir_func i32 @_Z8atom_decPU3AS1Vj(ptr addrspace(1) %gu)
  %call13 = tail call spir_func i32 @_Z8atom_decPU3AS3Vj(ptr addrspace(3) %lu)
  %call14 = tail call spir_func i32 @_Z8atom_decPU3AS1Vi(ptr addrspace(1) %gs)
  %call15 = tail call spir_func i32 @_Z8atom_decPU3AS3Vi(ptr addrspace(3) %ls)
  %call16 = tail call spir_func i32 @_Z14atomic_cmpxchgPU3AS1Vjjj(ptr addrspace(1) %gu, i32 7, i32 42)
  %call17 = tail call spir_func i32 @_Z14atomic_cmpxchgPU3AS3Vjjj(ptr addrspace(3) %lu, i32 7, i32 42)
  %call18 = tail call spir_func i32 @_Z14atomic_cmpxchgPU3AS1Viii(ptr addrspace(1) %gs, i32 7, i32 42)
  %call19 = tail call spir_func i32 @_Z14atomic_cmpxchgPU3AS3Viii(ptr addrspace(3) %ls, i32 7, i32 42)
  %call20 = tail call spir_func i32 @_Z12atom_cmpxchgPU3AS1Vjjj(ptr addrspace(1) %gu, i32 7, i32 42)
  %call21 = tail call spir_func i32 @_Z12atom_cmpxchgPU3AS3Vjjj(ptr addrspace(3) %lu, i32 7, i32 42)
  %call22 = tail call spir_func i32 @_Z12atom_cmpxchgPU3AS1Viii(ptr addrspace(1) %gs, i32 7, i32 42)
  %call23 = tail call spir_func i32 @_Z12atom_cmpxchgPU3AS3Viii(ptr addrspace(3) %ls, i32 7, i32 42)
  ret void
}

declare spir_func i32 @_Z10atomic_incPU3AS1Vj(ptr addrspace(1))
declare spir_func i32 @_Z10atomic_incPU3AS3Vj(ptr addrspace(3))
declare spir_func i32 @_Z10atomic_incPU3AS1Vi(ptr addrspace(1))
declare spir_func i32 @_Z10atomic_incPU3AS3Vi(ptr addrspace(3))
declare spir_func i32 @_Z8atom_incPU3AS1Vj(ptr addrspace(1))
declare spir_func i32 @_Z8atom_incPU3AS3Vj(ptr addrspace(3))
declare spir_func i32 @_Z8atom_incPU3AS1Vi(ptr addrspace(1))
declare spir_func i32 @_Z8atom_incPU3AS3Vi(ptr addrspace(3))
declare spir_func i32 @_Z10atomic_decPU3AS1Vj(ptr addrspace(1))
declare spir_func i32 @_Z10atomic_decPU3AS3Vj(ptr addrspace(3))
declare spir_func i32 @_Z10atomic_decPU3AS1Vi(ptr addrspace(1))
declare spir_func i32 @_Z10atomic_decPU3AS3Vi(ptr addrspace(3))
declare spir_func i32 @_Z8atom_decPU3AS1Vj(ptr addrspace(1))
declare spir_func i32 @_Z8atom_decPU3AS3Vj(ptr addrspace(3))
declare spir_func i32 @_Z8atom_decPU3AS1Vi(ptr addrspace(1))
declare spir_func i32 @_Z8atom_decPU3AS3Vi(ptr addrspace(3))
declare spir_func i32 @_Z14atomic_cmpxchgPU3AS1Vjjj(ptr addrspace(1), i32, i32)
declare spir_func i32 @_Z14atomic_cmpxchgPU3AS3Vjjj(ptr addrspace(3), i32, i32)
declare spir_func i32 @_Z14atomic_cmpxchgPU3AS1Viii(ptr addrspace(1), i32, i32)
declare spir_func i32 @_Z14atomic_cmpxchgPU3AS3Viii(ptr addrspace(3), i32, i32)
declare spir_func i32 @_Z12atom_cmpxchgPU3AS1Vjjj(ptr addrspace(1), i32, i32)
declare spir_func i32 @_Z12atom_cmpxchgPU3AS3Vjjj(ptr addrspace(3), i32, i32)
declare spir_func i32 @_Z12atom_cmpxchgPU3AS1Viii(ptr addrspace(1), i32, i32)
declare spir_func i32 @_Z12atom_cmpxchgPU3AS3Viii(ptr addrspace(3), i32, i32)


; CHECK: call i32 @_Z8spirv.op.232.PU3AS1jj(i32 232, ptr addrspace(1) %gu, i32 1, i32 80)
; CHECK: call i32 @_Z8spirv.op.232.PU3AS3jj(i32 232, ptr addrspace(3) %lu, i32 1, i32 80)
; CHECK: call i32 @_Z8spirv.op.232.PU3AS1jj(i32 232, ptr addrspace(1) %gs, i32 1, i32 80)
; CHECK: call i32 @_Z8spirv.op.232.PU3AS3jj(i32 232, ptr addrspace(3) %ls, i32 1, i32 80)
; CHECK: call i32 @_Z8spirv.op.232.PU3AS1jj(i32 232, ptr addrspace(1) %gu, i32 1, i32 80)
; CHECK: call i32 @_Z8spirv.op.232.PU3AS3jj(i32 232, ptr addrspace(3) %lu, i32 1, i32 80)
; CHECK: call i32 @_Z8spirv.op.232.PU3AS1jj(i32 232, ptr addrspace(1) %gs, i32 1, i32 80)
; CHECK: call i32 @_Z8spirv.op.232.PU3AS3jj(i32 232, ptr addrspace(3) %ls, i32 1, i32 80)
; CHECK: call i32 @_Z8spirv.op.233.PU3AS1jj(i32 233, ptr addrspace(1) %gu, i32 1, i32 80)
; CHECK: call i32 @_Z8spirv.op.233.PU3AS3jj(i32 233, ptr addrspace(3) %lu, i32 1, i32 80)
; CHECK: call i32 @_Z8spirv.op.233.PU3AS1jj(i32 233, ptr addrspace(1) %gs, i32 1, i32 80)
; CHECK: call i32 @_Z8spirv.op.233.PU3AS3jj(i32 233, ptr addrspace(3) %ls, i32 1, i32 80)
; CHECK: call i32 @_Z8spirv.op.233.PU3AS1jj(i32 233, ptr addrspace(1) %gu, i32 1, i32 80)
; CHECK: call i32 @_Z8spirv.op.233.PU3AS3jj(i32 233, ptr addrspace(3) %lu, i32 1, i32 80)
; CHECK: call i32 @_Z8spirv.op.233.PU3AS1jj(i32 233, ptr addrspace(1) %gs, i32 1, i32 80)
; CHECK: call i32 @_Z8spirv.op.233.PU3AS3jj(i32 233, ptr addrspace(3) %ls, i32 1, i32 80)
; CHECK: call i32 @_Z8spirv.op.230.PU3AS1jjjjj(i32 230, ptr addrspace(1) %gu, i32 1, i32 80, i32 80, i32 42, i32 7)
; CHECK: call i32 @_Z8spirv.op.230.PU3AS3jjjjj(i32 230, ptr addrspace(3) %lu, i32 1, i32 80, i32 80, i32 42, i32 7)
; CHECK: call i32 @_Z8spirv.op.230.PU3AS1jjjjj(i32 230, ptr addrspace(1) %gs, i32 1, i32 80, i32 80, i32 42, i32 7)
; CHECK: call i32 @_Z8spirv.op.230.PU3AS3jjjjj(i32 230, ptr addrspace(3) %ls, i32 1, i32 80, i32 80, i32 42, i32 7)
; CHECK: call i32 @_Z8spirv.op.230.PU3AS1jjjjj(i32 230, ptr addrspace(1) %gu, i32 1, i32 80, i32 80, i32 42, i32 7)
; CHECK: call i32 @_Z8spirv.op.230.PU3AS3jjjjj(i32 230, ptr addrspace(3) %lu, i32 1, i32 80, i32 80, i32 42, i32 7)
; CHECK: call i32 @_Z8spirv.op.230.PU3AS1jjjjj(i32 230, ptr addrspace(1) %gs, i32 1, i32 80, i32 80, i32 42, i32 7)
; CHECK: call i32 @_Z8spirv.op.230.PU3AS3jjjjj(i32 230, ptr addrspace(3) %ls, i32 1, i32 80, i32 80, i32 42, i32 7)

